package com.intellagric.controller.module.sys_user_log;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.SysUserLog;
import com.intellagric.pojo.SysUserLogWithBLOBs;
import com.intellagric.service.module.sys_user_log.UserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/10/30
 * @DESC： 用户操作日志管理
 */
@Controller
public class UserLogController {

    @Autowired
    private UserLogService userLogService;

    /**
     * 添加用户操作日志信息
     * @Param userLog
     * @return ResponseMessage
     */
    @RequestMapping("/userlog/add")
    @ResponseBody
    public ResponseMessage add(SysUserLogWithBLOBs userLog) {
        userLog.setId(UUID.randomUUID().toString().replaceAll("-",""));
        userLog.setCreateDate(new Date());
        return userLogService.addUserLog(userLog);
    }

    /**
     * 删除用户操作日志信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/userlog/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return userLogService.deleteUserLog(id);
    }


    /**
     * 查询用户操作日志信息
     * @return SysUserLog
     */
    @RequestMapping("/userlog/{id}")
    @ResponseBody
    public SysUserLog get(@PathVariable String id) {
        return userLogService.getUserLogById(id);
    }

    /**
     * 查询用户操作日志信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/userlog/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return userLogService.getUserLogList();
    }

    /**
     * 分页查询用户操作日志信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/userlog/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int rows) {
        return userLogService.getUserLogPage(page,rows);
    }

}
